package com.xyz.study.spring.event;

import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.stereotype.Component;

/**
 * TestSpringEventPublisher
 *
 * @author xyz
 * @version 1.0.0
 * @since 2021/7/23
 */
@Component
public class TestSpringEventPublisher implements ApplicationEventPublisherAware {
    private ApplicationEventPublisher publisher;

    @Override
    public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
        this.publisher = applicationEventPublisher;
    }

    public void publishEvent(String eventId, String name){
        publisher.publishEvent(new TestSpringEvent(new TestSpringEvent.EventData(eventId, name)));
    }
}
